package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.DisasterPrevention.RegionBean;
import com.project.mapper.IRegionMapper;
import com.project.service.IRegionService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("region")
public class RegionController {

    @Resource
    private IRegionService regionService;


    @RequestMapping("findCutRegion")
    public IPage<RegionBean> findCutRegion(@RequestParam(value = "pageNo",defaultValue = "1") int pageNo, @RequestParam(value = "pageSize",defaultValue = "3") int pageSize, String regionName, String regionForest, String className){

        IPage<RegionBean> page = regionService.findCutRegion(pageNo,pageSize,regionName,regionForest,className);

        return page;
    }

    @RequestMapping("addRegion")
    public String addRegion(RegionBean regionBean){
        if (regionBean != null){
            regionService.addRegion(regionBean);
        }

        return "ok";
    }

    @RequestMapping("findAll")
    public List<RegionBean> findAll(){

        List<RegionBean> list = regionService.findAll();

        return list;
    }





}
